<?php
/* -----------------------------------------------------------------
* 	ID:						$Id: default.php 2 2011-02-17 13:35:25Z akausch $
* 	Letzter Stand:			$Revision: 2 $
* 	zuletzt geändert von: 	$Author: akausch $
* 	Datum:					$Date: 2011-02-17 14:35:25 +0100 (Do, 17. Feb 2011) $
*
* 	commerce:SEO by Webdesign Erfurt
* 	http://www.commerce-seo.de
*
* 	Copyright (c) since 2010 commerce:SEO
* ------------------------------------------------------------------
* 	based on:
* 	(c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
* 	(c) 2002-2003 osCommerce - www.oscommerce.com
* 	(c) 2003     nextcommerce - www.nextcommerce.org
* 	(c) 2005     xt:Commerce - www.xt-commerce.com
*
* 	Released under the GNU General Public License
* --------------------------------------------------------------- */

$default_smarty = new smarty;

if ($mobile_template == 'False') {
	$default_smarty->assign('tpl_path', 'templates/'.CURRENT_TEMPLATE.'/');
} else {
	$default_smarty->assign('tpl_path', 'templates/'.CURRENT_MOBILE_TEMPLATE.'/');
}
$default_smarty->assign('session', session_id());
$main_content = '';

require_once (DIR_FS_INC.'xtc_customer_greeting.inc.php');
require_once (DIR_FS_INC.'xtc_get_path.inc.php');
require_once (DIR_FS_INC.'xtc_check_categories_status.inc.php');

if(xtc_check_categories_status($current_category_id) >= 1) {
	$error = CATEGORIE_NOT_FOUND;
	include (DIR_WS_MODULES.FILENAME_ERROR_HANDLER);

} else {
	if(GROUP_CHECK == 'true') {
		$group_check_c = "AND c.group_permission_".$_SESSION['customers_status']['customers_status_id']." = 1 "; // Kategorie
		$group_check_p = "AND p.group_permission_".$_SESSION['customers_status']['customers_status_id']." = 1 "; // Produkt
	}

	if ($category_depth == 'nested') {

		$category_query = "SELECT
		                    	cd.categories_description, 
								cd.categories_description_footer, 
		                    	cd.categories_name,
		          				cd.categories_heading_title,
		                        c.categories_template,
		                        c.categories_image,
		                        cd.categories_pic_alt
		                   FROM
		                   		".TABLE_CATEGORIES." c, ".TABLE_CATEGORIES_DESCRIPTION." cd
		                   WHERE
		                   		c.categories_id = '".$current_category_id."'
		                   AND
		                   		cd.categories_id = '".$current_category_id."'
		                        ".$group_check_c."
		                   AND
		                   		cd.language_id = '".(int) $_SESSION['languages_id']."'";

		$category_query = xtDBquery($category_query);
		$category = xtc_db_fetch_array($category_query, true);
		if(isset ($cPath) && preg_match('/_/', $cPath)) {
			$category_links = array_reverse($cPath_array);
			for ($i = 0, $n = sizeof($category_links); $i < $n; $i ++) {

				$categories_query = "SELECT
										cd.categories_description,
										c.categories_id,
										cd.categories_name,
										cd.categories_heading_title,
										c.categories_image,
										cd.categories_pic_alt,
										c.parent_id
									FROM
										".TABLE_CATEGORIES." c,
										".TABLE_CATEGORIES_DESCRIPTION." cd
									WHERE
										c.categories_status = '1'
									AND
										c.parent_id = '".$category_links[$i]."'
									AND
										c.categories_id = cd.categories_id
										".$group_check_c."
									AND
										cd.language_id = '".(int) $_SESSION['languages_id']."'
									ORDER BY
										sort_order, cd.categories_name";
				$categories_query = xtDBquery($categories_query);

				if (xtc_db_num_rows($categories_query, true) >= 1)
	    			break;
			}
		} else {

			$categories_query = "SELECT
									cd.categories_description,
									c.categories_id,
									cd.categories_name,
									cd.categories_heading_title,
									c.categories_image,
									cd.categories_pic_alt,
									c.parent_id
								FROM
									".TABLE_CATEGORIES." c, ".TABLE_CATEGORIES_DESCRIPTION." cd
								WHERE
									c.categories_status = '1'
								AND
									c.parent_id = '".$current_category_id."'
								AND
									c.categories_id = cd.categories_id
									".$group_check_c."
								AND
									cd.language_id = '".(int) $_SESSION['languages_id']."'
								ORDER BY
									sort_order, cd.categories_name";
			$categories_query = xtDBquery($categories_query);
		}

		$rows = 0;
		while ($categories = xtc_db_fetch_array($categories_query, true)) {
			$rows ++;

			$cPath_new = xtc_category_link($categories['categories_id'],$categories['categories_name']);

			$image = '';
			if ($categories['categories_image'] != '')
				$image = DIR_WS_IMAGES.'categories/'.$categories['categories_image'];
			
			$categories_content[] = array ('CATEGORIES_NAME' => $categories['categories_name'],
	  										'CATEGORIES_HEADING_TITLE' => $categories['categories_heading_title'],
	  										'CATEGORIES_IMAGE' => $image,
	  										'CATEGORIES_IMAGE_ALT' => ($categories['categories_pic_alt'] !='' ? $categories['categories_pic_alt'] : $categories['categories_name']),
	  										'CATEGORIES_IMAGE_DIMENSION' => cseo_get_img_size($image),
	  										'CATEGORIES_LINK' => xtc_href_link(FILENAME_DEFAULT, $cPath_new),
	  										'CATEGORIES_DESCRIPTION' => strip_tags($categories['categories_description']),
	  										'CATEGORIES_DESCRIPTION_FOOTER' => $categories['categories_description_footer']);
		}
		$new_products_category_id = $current_category_id;
		include (DIR_WS_MODULES.FILENAME_NEW_PRODUCTS);

		$image = '';
		if ($category['categories_image'] != '') {
			$image = DIR_WS_IMAGES.'categories/'.$category['categories_image'];
		}
		$default_smarty->assign('CATEGORIES_NAME', $category['categories_name']);
		$default_smarty->assign('CATEGORIES_HEADING_TITLE', $category['categories_heading_title']);

		$default_smarty->assign('CATEGORIES_IMAGE', $image);
		$default_smarty->assign('CATEGORIES_DESCRIPTION', $category['categories_description']);
		$default_smarty->assign('CATEGORIES_DESCRIPTION_FOOTER', $category['categories_description_footer']);
		$default_smarty->assign('CATEGORIES_IMAGE_ALT', $category['categories_pic_alt'] !='' ? $category['categories_pic_alt'] : $category['categories_name']);
		$default_smarty->assign('CATEGORIES_IMAGE_DIMENSION', cseo_get_img_size($image));
		
		$default_smarty->assign('language', $_SESSION['language']);
		$default_smarty->assign('CATEGORIES_LIST', $module_categories);
		$default_smarty->assign('module_content', $categories_content);

		#Mobile Template
		if ($mobile_template == 'False') {
			if($category['categories_template'] == '' or $category['categories_template'] == 'default') {
				$files = array ();
				if($dir = opendir(DIR_FS_CATALOG.'templates/'.CURRENT_TEMPLATE.'/module/categorie_listing/')) {
					while(($file = readdir($dir)) !== false) {
						if(is_file(DIR_FS_CATALOG.'templates/'.CURRENT_TEMPLATE.'/module/categorie_listing/'.$file) && (substr($file, -5) == '.html') && ($file != 'index.html') && (substr($file, 0, 1) !='.'))
							$files[] = $file;
					}
					closedir($dir);
				}
				sort($files);
				$category['categories_template'] = $files[0];
			}
		} else {
			if($category['categories_template'] == '' or $category['categories_template'] == 'default') {
				$files = array ();
				if($dir = opendir(DIR_FS_CATALOG.'templates/'.CURRENT_MOBILE_TEMPLATE.'/module/categorie_listing/')) {
					while(($file = readdir($dir)) !== false) {
						if(is_file(DIR_FS_CATALOG.'templates/'.CURRENT_MOBILE_TEMPLATE.'/module/categorie_listing/'.$file) && (substr($file, -5) == '.html') && ($file != 'index.html') && (substr($file, 0, 1) !='.'))
							$files[] = $file;
					}
					closedir($dir);
				}
				sort($files);
				$category['categories_template'] = $files[0];
			}
		}		
		#Mobile END
		
		$default_smarty->caching = 0;
		if ($mobile_template == 'False') {
			$main_content = $default_smarty->fetch(CURRENT_TEMPLATE.'/module/categorie_listing/'.$category['categories_template']);
		} else {
			$main_content = $default_smarty->fetch(CURRENT_MOBILE_TEMPLATE.'/module/categorie_listing/'.$category['categories_template']);
		}
		
		$smarty->assign('main_content', $main_content);
	}
	elseif ($category_depth == 'products' || ($_GET['manufacturers_id'] && $_GET['manufacturers_id'] !='')) {
  	//fsk18 lock
	$fsk_lock = '';
	if($_SESSION['customers_status']['customers_fsk18_display'] == '0')
		$fsk_lock = ' and p.products_fsk18!=1';

	if(isset($_GET['manufacturers_id'])) {

 		$sorting_query = xtDBquery("SELECT products_sorting, products_sorting2 FROM ".TABLE_CATEGORIES." WHERE categories_id='".$new_products_category_id."'");
		$sorting_data = xtc_db_fetch_array($sorting_query,true);

		if($sorting_data['products_sorting'] == '')
			$sorting_data['products_sorting'] = 'pd.products_name';

	  	if(isset($_GET['filter_id']) && xtc_not_null($_GET['filter_id'])) {

			switch ($_GET['multisort']){
			    case 'specialprice':
			      $sorting = 'ORDER BY s.specials_new_products_price DESC';
				  $field = ' INNER JOIN '.TABLE_SPECIALS.' s ';
			      break;
			    case 'new_asc':
			      $sorting = ' ORDER BY p.products_date_added ASC';
			      break;
			    case 'new_desc':
			      $sorting = ' ORDER BY p.products_date_added DESC';
			      break;
			    case 'name_asc':
			      $sorting = ' ORDER BY pd.products_name ASC';
			      break;
			    case 'name_desc':
			      $sorting = ' ORDER BY pd.products_name DESC';
			      break;
			    case 'price_asc':
			      $sorting = ' ORDER BY p.products_price ASC';
			      break;
			    case 'price_desc':
			      $sorting = ' ORDER BY p.products_price DESC';
			      break;
			    case 'manufacturer_asc':
			      $sorting = ' ORDER BY m.manufacturers_name ASC';
			      break;
			    case 'manufacturer_desc':
			      $sorting = ' ORDER BY m.manufacturers_name DESC';
			      break;
			    default:
			      $sorting = ' ORDER BY '.$sorting_data['products_sorting'].' '.$sorting_data['products_sorting2'].' ';
		 	}

	    // We are asked to show only a specific category
	    $listing_sql = "select DISTINCT p.products_fsk18,
	                                  p.products_shippingtime,
	                                  p.products_model,
	                                  p.manufacturers_id,
	                                  pd.products_name,
	                                  p.products_ean,
	                                  p.products_price,
	                                  p.products_tax_class_id,
	                                  m.manufacturers_name,
	                                  p.products_quantity,
	                                  p.products_image,
	                                  p.products_weight,
	                                  pd.products_short_description,
	                                  pd.products_description,
	                                  pd.products_img_alt,
	                                  p.products_id,
	                                  p.manufacturers_id,
	                                  p.products_price,
	                                  p.products_vpe,
	                                  p.products_vpe_status,
	                                  p.products_vpe_value,
	                                  p.products_discount_allowed,
	                                  p.products_tax_class_id
	                                  from ".TABLE_PRODUCTS_DESCRIPTION." pd,
	                                  		".TABLE_PRODUCTS_TO_CATEGORIES." p2c,
	                                  		".TABLE_PRODUCTS." p
	                                  INNER JOIN ".TABLE_MANUFACTURERS." m
									".$field."
	                                  where p.products_status = '1'
	                                  and p.manufacturers_id = m.manufacturers_id
	                                  and m.manufacturers_id = '".(int) $_GET['manufacturers_id']."'
	                                  and p.products_id = p2c.products_id
	                                  and pd.products_id = p2c.products_id
	                                  ".$group_check_p."
	                                  ".$fsk_lock."
	                                  and pd.language_id = '".(int) $_SESSION['languages_id']."'
	                                  and p2c.categories_id = '".(int) $_GET['filter_id']."'".$sorting;
	  } else {

			switch ($_GET['multisort']) {
			    case 'specialprice':
			      $sorting = 'ORDER BY s.specials_new_products_price DESC';
				  $field = 'INNER JOIN '.TABLE_SPECIALS.' s ';
			      break;
			    case 'new_asc':
			      $sorting = ' ORDER BY p.products_date_added ASC';
			      break;
			    case 'new_desc':
			      $sorting = ' ORDER BY p.products_date_added DESC';
			      break;
			    case 'name_asc':
			      $sorting = ' ORDER BY pd.products_name ASC';
			      break;
			    case 'name_desc':
			      $sorting = ' ORDER BY pd.products_name DESC';
			      break;
			    case 'price_asc':
			      $sorting = ' ORDER BY p.products_price ASC';
			      break;
			    case 'price_desc':
			      $sorting = ' ORDER BY p.products_price DESC';
			      break;
			    case 'manufacturer_asc':
			      $sorting = ' ORDER BY m.manufacturers_name ASC';
			      break;
			    case 'manufacturer_desc':
			      $sorting = ' ORDER BY m.manufacturers_name DESC';
			      break;
			    default:
			    	$sorting = ' ORDER BY '.$sorting_data['products_sorting'].' '.$sorting_data['products_sorting2'].' ';
			}
			$listing_sql = "SELECT
								p.products_fsk18,
								p.products_shippingtime,
								p.products_model,
								p.manufacturers_id,
								p.products_ean,
								pd.products_name,
								p.products_id,
								p.products_price,
								m.manufacturers_name,
								p.products_quantity,
								p.products_image,
								pd.products_img_alt,
								p.products_weight,
								pd.products_short_description,
								pd.products_description,
								p.manufacturers_id,
								p.products_vpe,
								p.products_vpe_status,
								p.products_vpe_value,
								p.products_discount_allowed,
								p.products_tax_class_id
							FROM
								".TABLE_PRODUCTS_DESCRIPTION." pd,
								".TABLE_PRODUCTS." p
								INNER JOIN ".TABLE_MANUFACTURERS." m
							".$field."
							WHERE
								p.products_status = '1'
							AND
								pd.products_id = p.products_id
							AND
								pd.language_id = '".(int) $_SESSION['languages_id']."'
							AND
								p.manufacturers_id = m.manufacturers_id
							AND
								m.manufacturers_id = '".(int) $_GET['manufacturers_id']."'".
								$group_check_p.$fsk_lock.$sorting;
			}

	  } else {

	 	if (isset($_GET['filter_id']) && xtc_not_null($_GET['filter_id'])) {
		    // sorting query
		    $sorting_query = xtDBquery("SELECT products_sorting, products_sorting2 FROM ".TABLE_CATEGORIES." WHERE categories_id='".$current_category_id."'");
		    $sorting_data = xtc_db_fetch_array($sorting_query,true);
		    if($sorting_data['products_sorting']=='')
			    $sorting_data['products_sorting'] = 'pd.products_name';
		    $sorting = ' ORDER BY '.$sorting_data['products_sorting'].' '.$sorting_data['products_sorting2'].' ';

		    switch ($_GET['multisort']) {
			    case 'specialprice':
			      $field = ' INNER JOIN '.TABLE_SPECIALS.' s';
			      $sorting = 'ORDER BY s.specials_new_products_price DESC';
			      break;
			    case 'new_asc':
			      $sorting = ' ORDER BY p.products_date_added ASC';
			      break;
			    case 'new_desc':
			      $sorting = ' ORDER BY p.products_date_added DESC';
			      break;
			    case 'name_asc':
			      $sorting = ' ORDER BY pd.products_name ASC';
			      break;
			    case 'name_desc':
			      $sorting = ' ORDER BY pd.products_name DESC';
			      break;
			    case 'price_asc':
			      $sorting = ' ORDER BY p.products_price ASC';
			      break;
			    case 'price_desc':
			      $sorting = ' ORDER BY p.products_price DESC';
			      break;
			    case 'manufacturer_asc':
			      $sorting = ' ORDER BY m.manufacturers_name ASC';
			      break;
			    case 'manufacturer_desc':
			      $sorting = ' ORDER BY m.manufacturers_name DESC';
			      break;
			    default:
			    	$sorting = ' ORDER BY '.$sorting_data['products_sorting'].' '.$sorting_data['products_sorting2'].' ';
			  }
		    $listing_sql = "SELECT
		    					p.products_fsk18,
								p.products_shippingtime,
								p.products_model,
								p.manufacturers_id,
								p.products_ean,
								pd.products_name,
								p.products_id,
								m.manufacturers_name,
								p.products_quantity,
								p.products_image,
								p.products_weight,
								pd.products_short_description,
								pd.products_description,
								pd.products_img_alt,
								p.manufacturers_id,
								p.products_price,
								p.products_vpe,
								p.products_vpe_status,
								p.products_vpe_value,
								p.products_discount_allowed,
								p.products_tax_class_id
							FROM
								".TABLE_PRODUCTS_DESCRIPTION." pd,
								".TABLE_PRODUCTS_TO_CATEGORIES." p2c,
								".TABLE_PRODUCTS." p
								INNER JOIN ".TABLE_MANUFACTURERS." m
								".$field."
							WHERE
								p.products_status = '1'
							AND
								p.manufacturers_id = m.manufacturers_id
							AND
								m.manufacturers_id = '".(int) $_GET['filter_id']."'
							AND
								p.products_id = p2c.products_id
							AND
								pd.products_id = p2c.products_id
							AND
								pd.language_id = '".(int) $_SESSION['languages_id']."'
							AND
								p2c.categories_id = '".$current_category_id."'"
								.$group_check_p
								.$fsk_lock
								.$sorting;
	  } else {

	    $sorting_query = xtDBquery("SELECT products_sorting, products_sorting2 FROM ".TABLE_CATEGORIES." where categories_id='".$current_category_id."'");
	    $sorting_data = xtc_db_fetch_array($sorting_query,true);
	    if(!$sorting_data['products_sorting'])
	    	$sorting_data['products_sorting'] = 'pd.products_name';
	    $sorting = ' ORDER BY '.$sorting_data['products_sorting'].' '.$sorting_data['products_sorting2'].' ';

	    switch ($_GET['multisort']) {
		    case 'specialprice':
		      $sorting = 'ORDER BY s.specials_new_products_price DESC';
			  $field = 'INNER JOIN '.TABLE_SPECIALS.' s ';
		      break;
		    case 'new_asc':
		      $sorting = ' ORDER BY p.products_date_added ASC';
		      break;
		    case 'new_desc':
		      $sorting = ' ORDER BY p.products_date_added DESC';
		      break;
		    case 'name_asc':
		      $sorting = ' ORDER BY pd.products_name ASC';
		      break;
		    case 'name_desc':
		      $sorting = ' ORDER BY pd.products_name DESC';
		      break;
		    case 'price_asc':
		      $sorting = ' ORDER BY p.products_price ASC';
		      break;
		    case 'price_desc':
		      $sorting = ' ORDER BY p.products_price DESC';
		      break;
		    default:
		    	$sorting = ' ORDER BY '.$sorting_data['products_sorting'].' '.$sorting_data['products_sorting2'].' ';
		}
		$listing_sql = "SELECT p.products_fsk18,
							p.products_shippingtime,
							p.products_model,
							p.manufacturers_id,
							p.products_ean,
							pd.products_name,
							p.products_quantity,
							p.products_image,
							p.products_weight,
							pd.products_short_description,
							pd.products_description,
							pd.products_img_alt,
							p.products_id,
							p.products_price,
							p.products_vpe,
							p.products_vpe_status,
							p.products_vpe_value,
							p.products_discount_allowed,
							p.products_tax_class_id
             			FROM
             				".TABLE_PRODUCTS." p
						INNER JOIN 
							".TABLE_PRODUCTS_TO_CATEGORIES." p2c ON (p2c.categories_id = '".$current_category_id."')
						INNER JOIN 
							".TABLE_PRODUCTS_DESCRIPTION." pd ON (pd.products_id = p2c.products_id AND pd.language_id = '".(int)$_SESSION['languages_id']."')
							$field
						WHERE
							p.products_status = '1'
                        AND
							p.products_id = p2c.products_id
						".$group_check_p."
						".$fsk_lock."
						".$sorting;
		}
	}

		if(isset($_GET['manufacturers_id'])) {
			$filterlist_sql = "SELECT DISTINCT
									c.categories_id as id,
									cd.categories_name as name
								FROM
									".TABLE_PRODUCTS." p,
									".TABLE_PRODUCTS_TO_CATEGORIES." p2c,
									".TABLE_CATEGORIES." c,
									".TABLE_CATEGORIES_DESCRIPTION." cd
								WHERE
									p.products_status = '1'
								AND
									p.products_id = p2c.products_id
								AND
									p2c.categories_id = c.categories_id
								AND
									p2c.categories_id = cd.categories_id
								AND
									cd.language_id = '".(int) $_SESSION['languages_id']."'
								AND
									p.manufacturers_id = '".(int) $_GET['manufacturers_id']."'
								ORDER BY
									cd.categories_name";
		} else {
			$filterlist_sql = "SELECT DISTINCT
									m.manufacturers_id as id,
									m.manufacturers_name as name
								FROM
									".TABLE_PRODUCTS." p,
									".TABLE_PRODUCTS_TO_CATEGORIES." p2c,
									".TABLE_MANUFACTURERS." m
								WHERE
									p.products_status = '1'
								AND
									p.manufacturers_id = m.manufacturers_id
								AND
									p.products_id = p2c.products_id
								AND
									p2c.categories_id = '".$current_category_id."'
								ORDER BY
									m.manufacturers_name";
		}

		$filterlist_query = xtDBquery($filterlist_sql);
		if (xtc_db_num_rows($filterlist_query, true) > 1) {
		    $manufacturer_dropdown = xtc_draw_form('filter', $_SERVER['REQUEST_URI'], 'get');
		    if (isset ($_GET['manufacturers_id'])) {
		    	$manufacturer_dropdown .= xtc_draw_hidden_field('manufacturers_id', (int)$_GET['manufacturers_id']);
		    	$options = array (array ('text' => TEXT_ALL_CATEGORIES));
		    } else {
		    	$options = array (array ('text' => TEXT_ALL_MANUFACTURERS));
		    }
			if($_GET['page'] != '')
		   		$manufacturer_dropdown .= xtc_draw_hidden_field('page', $_GET['page']);

		    if($_GET['cPath'] != '' && MODULE_COMMERCE_SEO_INDEX_STATUS != 'True')
		   		$manufacturer_dropdown .= xtc_draw_hidden_field('cPath', $_GET['cPath']);
		    if($_GET['multisort'] != '')
		   		$manufacturer_dropdown .= xtc_draw_hidden_field('multisort', $_GET['multisort']);

		   	if($_GET['result'] != '')
		   		$manufacturer_dropdown .= xtc_draw_hidden_field('result', $_GET['result']);

		    while ($filterlist = xtc_db_fetch_array($filterlist_query, true))
		    	$options[] = array ('id' => $filterlist['id'], 'text' => $filterlist['name']);

		    $manufacturer_dropdown .= xtc_draw_pull_down_menu('filter_id', $options, $_GET['filter_id'], 'onchange="javascript:this.form.submit();"');
		    $manufacturer_dropdown .= '</form>'."\n";
		}

		if(PRODUCT_LIST_FILTER_SORT == 'true') {
			$multisort_dropdown = xtc_draw_form('multisort', $_SERVER['REQUEST_URI'], 'GET') . "\n";

			if($_GET['page'] != '')
		   		$multisort_dropdown .= xtc_draw_hidden_field('page', $_GET['page']);

		    if($_GET['cPath'] != '' && MODULE_COMMERCE_SEO_INDEX_STATUS != 'True')
		   		$multisort_dropdown .= xtc_draw_hidden_field('cPath', $_GET['cPath']);
			if (isset($_GET['manufacturers_id']))
				$multisort_dropdown .= xtc_draw_hidden_field('manufacturers_id', $_GET['manufacturers_id']);
				
		   	if($_GET['result'] != '')
		   		$manufacturer_dropdown .= xtc_draw_hidden_field('result', $_GET['result']);
				

			if(isset($_GET['filter_id']))
				$multisort_dropdown .= xtc_draw_hidden_field('filter_id', (int)$_GET['filter_id']);

			$options = array(
			  array('text' => MULTISORT_STANDARD));
				$options[] =
				  array('id' => 'specialprice',
				        'text' => MULTISORT_SPECIALS_DESC);
				$options[] =
				  array('id' => 'new_desc',
				        'text' => MULTISORT_NEW_DESC);
				$options[] =
				  array('id' => 'new_asc',
				        'text' => MULTISORT_NEW_ASC);
				$options[] =
				  array('id' => 'price_asc',
				        'text' => MULTISORT_PRICE_ASC);
				$options[] =
				  array('id' => 'price_desc',
				        'text' => MULTISORT_PRICE_DESC);
				$options[] =
				  array('id' => 'name_asc',
				        'text' => MULTISORT_ABC_AZ);
				$options[] =
				  array('id' => 'name_desc',
				        'text' => MULTISORT_ABC_ZA);
				$options[] =
				  array('id' => 'manufacturer_asc',
				        'text' => MULTISORT_MANUFACTURER_ASC);
				$options[] =
				  array('id' => 'manufacturer_desc',
				        'text' => MULTISORT_MANUFACTURER_DESC);

			$multisort_dropdown .= xtc_draw_pull_down_menu('multisort', $options, $_GET['multisort'], 'onchange="javascript:this.form.submit();"') . "\n";
			$multisort_dropdown .= '</form>' . "\n";
		}

		include (DIR_WS_MODULES.FILENAME_PRODUCT_LISTING);

	} else { // default page
		if (GROUP_CHECK == 'true')
			$group_check = " AND group_ids LIKE '%c_".$_SESSION['customers_status']['customers_status_id']."_group%'";

		$shop_content_query = xtDBquery("SELECT
										content_title,
					                      content_heading,
					                      content_text,
					                      content_file
					                      FROM ".TABLE_CONTENT_MANAGER."
					                      WHERE content_group='5'
					                      ".$group_check."
					                      AND languages_id='".$_SESSION['languages_id']."'");
		$shop_content_data = xtc_db_fetch_array($shop_content_query,true);

		$default_smarty -> assign('title', utf8_decode(($shop_content_data['content_heading'])));
		include (DIR_WS_INCLUDES.FILENAME_CENTER_MODULES);

		if ($shop_content_data['content_file'] != '') {
			ob_start();
			if (strpos($shop_content_data['content_file'], '.txt'))
				echo '<pre>';

			include (DIR_FS_CATALOG.'media/content/'.$shop_content_data['content_file']);

			if (strpos($shop_content_data['content_file'], '.txt'))
				echo '</pre>';
				$shop_content_data['content_text'] = ob_get_contents();
				ob_end_clean();
			}
			$default_smarty->assign('text', str_replace('{$greeting}', xtc_customer_greeting(), $shop_content_data['content_text']));
			$default_smarty->assign('language', $_SESSION['language']);

	  // set cache ID
		if(!CacheCheck()) {
	  		$default_smarty->caching = 0;
			if ($mobile_template == 'False') {
				$main_content = $default_smarty->fetch(CURRENT_TEMPLATE.'/module/main_content.html');
			} else {
				$main_content = $default_smarty->fetch(CURRENT_MOBILE_TEMPLATE.'/module/main_content.html');
			}
	  	} else {
	  		$default_smarty->caching = 1;
	  		$default_smarty->cache_lifetime = CACHE_LIFETIME;
	  		$default_smarty->cache_modified_check = CACHE_CHECK;
	  		$cache_id = $_SESSION['language'].$_SESSION['currency'].$_SESSION['customer_id'];
			if ($mobile_template == 'False') {
				$main_content = $default_smarty->fetch(CURRENT_TEMPLATE.'/module/main_content.html', $cache_id);
			} else {
				$main_content = $default_smarty->fetch(CURRENT_MOBILE_TEMPLATE.'/module/main_content.html', $cache_id);
			}	  		
	  	}
	  	$smarty->assign('main_content', $main_content);
	}
}
?>